import datetime

from sqlalchemy import Column, Integer, String, create_engine, Date
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

Base = declarative_base()


class ExpiringContract(Base):
    __tablename__ = 'expiring_contract'
    serial_number = Column(Integer, primary_key=True, autoincrement=True)
    expiry_date = Column(Date)
    shop_name = Column(String(50))
    code_id = Column(String(50))
    principal = Column(String(150))


# 初始化数据库连接:
engine = create_engine('mysql+pymysql://apidb:19970405@moonwife.top:3306/apidb?charset=utf8', echo=True)
# 创建DBSession类型:
DBSession = sessionmaker(bind=engine)
session = DBSession()
Base.metadata.create_all(engine)
session.commit()
